 
xquery version "1.0";



import module namespace request="http://exist-db.org/xquery/request";
import module namespace session="http://exist-db.org/xquery/session";
import module namespace util="http://exist-db.org/xquery/util";

import module namespace iatistats="http://iatiui.ampdev.net/iatistats" at "statistics.xql";

declare option exist:serialize "method=xhtml media-type=text/html";

declare function local:get_html_from_map($type) {
  for $entry in iatistats:cached_stats($type)
  return 
      <tr><td>{$entry/key}</td><td>{$entry/value}</td></tr>
};


<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title>Quick statistics</title>
    </head>
    <body style="background-color: rgb(255, 255, 255); border-radius: 10px 10px 10px 10px; padding: 10px 15px;">
		<h2 style="border-bottom: 1px solid #CECECE; color: #00734A;font-size: 24px;font-weight: normal;margin: 0 0 15px;padding: 0 0 5px;"> 
                                Number of Feeds per Organization
		</h2>
        
		<table style="border-collapse: collapse; clear: left; font-size: 14px; margin: 5px 0pt;" border="1">
                <tr>
					<th style="border-collapse: collapse; clear: left; font-size: 14px; margin: 5px 0pt;">Organisation</th>
                	<th style="border-collapse: collapse; clear: left; font-size: 14px; margin: 5px 0pt;">Number of Feeds</th>
                </tr>
               
		   { local:get_html_from_map('feeds') }
           
               
		</table> 

		<br />
        <br />
        <h2 style=" border-bottom: 1px solid #CECECE; color: #00734A;font-size: 24px;font-weight: normal;margin: 0 0 15px;padding: 0 0 5px;"> 
                                Number of Projects per Organization
		</h2>

			<table style="border-collapse: collapse; clear: left; font-size: 14px; margin: 5px 0pt;" border="1">
				<tr>
	                <th style="border-collapse: collapse; clear: left; font-size: 14px; margin: 5px 0pt;">Organisation</th>
	                <th style="border-collapse: collapse; clear: left; font-size: 14px; margin: 5px 0pt;">Number of Activities</th>
	            </tr>
               
		    { local:get_html_from_map('iati-activity')}
           
               
            </table> 

       
    </body>
</html>
